home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / WizardViewDbConnection.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  4.0 KB  |  100 lines

  1. package asp.wizard;
  2.  
  3. import asp.netobjects.nfx.wizard.WizardPageView;
  4. import asp.wizard.util.DataSourceDesc;
  5. import asp.wizard.util.UiUtil;
  6. import com.sun.java.swing.AbstractButton;
  7. import com.sun.java.swing.ComboBoxModel;
  8. import com.sun.java.swing.JButton;
  9. import com.sun.java.swing.JComboBox;
  10. import java.util.Vector;
  11.  
  12. public class WizardViewDbConnection extends WizardViewAbstract {
  13.    private static WizardViewAbstract _instance = null;
  14.    private WVPanelDbConnection _mainPanel;
  15.  
  16.    public static WizardViewAbstract getInstance() {
  17.       if (_instance == null) {
  18.          _instance = new WizardViewDbConnection();
  19.       }
  20.  
  21.       return _instance;
  22.    }
  23.  
  24.    protected void createMainPanel() {
  25.       this._mainPanel = new WVPanelDbConnection();
  26.       JButton btnConn = this._mainPanel._btnTestConn;
  27.       ((AbstractButton)btnConn).addActionListener(new 1(this));
  28.    }
  29.  
  30.    public WVPanelBase getMainPanel() {
  31.       return this._mainPanel;
  32.    }
  33.  
  34.    public void updateDataSources() {
  35.       Vector dataSources = WizDbManager.getInstance().getDataSources();
  36.       JComboBox cboOdbcDsn = this._mainPanel._cboOdbcDsn;
  37.       cboOdbcDsn.removeAllItems();
  38.       UiUtil.addItemToComboBox(dataSources, cboOdbcDsn);
  39.    }
  40.  
  41.    private void testConnection() {
  42.       ((WizardModelDbConnection)((WizardPageView)this).getModel()).testConnection();
  43.    }
  44.  
  45.    public void setDSNName(String dsn) {
  46.       JComboBox cboDsn = this._mainPanel._cboOdbcDsn;
  47.       cboDsn.setSelectedItem("##");
  48.       ComboBoxModel cm = cboDsn.getModel();
  49.       int dsnIndex = UiUtil.getListModelIndexByString(cm, dsn);
  50.       if (dsnIndex != -1) {
  51.          cboDsn.setSelectedIndex(dsnIndex);
  52.       }
  53.  
  54.    }
  55.  
  56.    public void setUserName(String userName) {
  57.       this._mainPanel._txfUser.setText(userName);
  58.    }
  59.  
  60.    public void setPassword(String password) {
  61.       this._mainPanel._txfPwd.setText(password);
  62.    }
  63.  
  64.    public void setGlobalConnection(int globalConnection) {
  65.    }
  66.  
  67.    public int getOdbcType() {
  68.       int result = -1;
  69.       DataSourceDesc dsd = (DataSourceDesc)this._mainPanel._cboOdbcDsn.getSelectedItem();
  70.       if (dsd.getType().toUpperCase().indexOf("ACCESS") > -1) {
  71.          result = 0;
  72.       } else if (dsd.getType().toUpperCase().indexOf("SQL SERVER") > -1) {
  73.          result = 1;
  74.       }
  75.  
  76.       return result;
  77.    }
  78.  
  79.    public String getDSNName() {
  80.       return this._mainPanel._cboOdbcDsn.getSelectedItem().toString();
  81.    }
  82.  
  83.    public String getUserName() {
  84.       return this._mainPanel._txfUser.getText();
  85.    }
  86.  
  87.    public String getPassword() {
  88.       return this._mainPanel._txfPwd.getText();
  89.    }
  90.  
  91.    public int getGlobalConnection() {
  92.       return 1;
  93.    }
  94.  
  95.    // $FF: synthetic method
  96.    static void access$0(WizardViewDbConnection $0) {
  97.       $0.testConnection();
  98.    }
  99. }
  100.